/**
 * Created by Administrator on 2017/5/31 0031.
 */

$(function () {

    var proId = parseInt(window.location.search.split('=')[1])-1;
    //console.log(proId);
    $.getJSON({
        url: "json/list.json",
        success: function (res){
            $(".detail_head>ul").append("<li>"+ res[proId].proText +"</li>");

            $(".goods_img").append("<div style='background-image: url("+ res[proId].proimg +")'></div>");

            $(".goods_data").prepend("<h1>"+ res[proId].proTitle + res[proId].proText +"</h1>")

            $(".goods_data>dl").eq(0).children("dd").children("div").append("<span class='price'>"+ res[proId].proprice +"</span>")

            $(".addcart").data("proImg", res[proId].proImg);
            $(".addcart").data("proTitle", res[proId].proTitle);
            $(".addcart").data("proText", res[proId].proText);
            $(".addcart").data("proPrice", res[proId].proprice);
            $(".addcart").data("proId", res[proId].proId);
        }

    });
    $(".addcart").on("click",function () {
        $.ajax({
            url: "http://127.0.0.1/daling/addcartlist.php",
            type: "get",
            data: {
                "proImg": $(this).data("proImg"),
                "proTitle": $(this).data("proTitle"),
                "proText": $(this).data("proText"),
                "proPrice": $(this).data("proPrice"),
                "proId": $(this).data("proId")
            },
            success: function (res) {
            }
        })
    })



});

